<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <title>账号明细</title>
    <link rel="stylesheet" href="../css/admin.css">
     <link rel="stylesheet" href="../layui/css/layui.css">
    <link rel="stylesheet" href="../fonts/iconfont.css">
</head>
<style>
  *{
   margin:0;
   padding:0;
}
.top{
  width:100%;
  margin-top: 20px;
}
.top .text-check{
  font-size:14px;
  display: inline-block;
}
.chose{
  color:#888;
  margin-left: 10px;
  display: inline-block;
}
.layui-inline{
  margin-left:8px;
  display: inline-block;
}
.layui-input-inline{
  width:120px;
  display: inline-block;
}
.layui-form-label{
  width:32px;
  padding:2px 10px 5px 4px;
  border:1px solid #888;
  border-right:none;
  border-top-left-radius:5px;
  border-bottom-left-radius:5px;
}
.layui-input{
  height:29px;
  width:120px;
  border:1px solid #888;
  border-left:none;
  outline:none;
  font-size: 14px;
  border-top-left-radius:0;
  border-bottom-left-radius:0;
  border-top-right-radius:5px;
  border-bottom-right-radius:5px;
  display: inline-block;
}
.layui-btn,.layui-btn-outer{
  color:white;
  border:0;
  height:28px;
  line-height: 28px;
  font-size:14px;
  outline: none;
  border-radius:5px;
  display: inline-block;
  background-color: #EF7632;
}
.layui-btn{
  width:92px;
}
.layui-btn-outer{
  width:160px;
  margin-left:40px;
}
/* table部分 */
.detail{
  height:600px;
}
.layui-table[lay-skin=line] td, .layui-table[lay-skin=line] th{
  background-color:#fff;
}
/* 分页 */
#page-num{
    display: inline-block;
 }
 .layui-laypage a, .layui-laypage span{
  border:none;
  border-radius:30px;
  text-align: center;
  width: 20px;
  height: 20px;
  line-height:20px;
  padding:0;
  margin-left:3px;
 }
 .layui-laypage>:first-child, .layui-laypage>:first-child em{
  border-radius:30px;
 }
.layui-laypage>:last-child, .layui-laypage>:last-child em{
  border-radius:30px;
}
.layui-laypage .layui-laypage-curr .layui-laypage-em{
  border-radius:30px;
  background-color: #EF7632;
}
#page-fen{
    display: inline-block;
    float: right;
}
#page-counter{
  display: inline-block;
}
#page-num{
display: inline-block;
margin-left:15px;
margin-right:30px;
}
.goBack{
  margin-left: 20px;
}
</style>
<body>
<div class="container-one">
  <div class="top">
    <p class=text-check>查看消费类型</p>
    <form class="layui-form layui-form-pane chose" >
          <input type="radio" name="items" value="flow" title="全部" checked>
          <input type="radio" name="items" value="chengti" title="乘梯">
          <input type="radio" name="items" value="chongzhi" title="充值">
    </form>
    <!-- 日期 -->
    <div class="layui-inline">
          <label class="layui-form-label">日期</label><div class="layui-input-inline">
            <input type="text" class="layui-input layui-date" placeholder="" id="start">
          </div>
        </div>
        <span>至</span>
        <div class="layui-inline">
          <label class="layui-form-label">日期</label><div class="layui-input-inline">
            <input type="text" class="layui-input layui-date" placeholder=""  id="end">
          </div>
        </div>
    <button class="layui-btn" id="search" lay-submit=""><span class="iconfont icon-sousuokuang"></span>&emsp;搜&nbsp;索</button>
     <!-- <input type="button" onclick="outerDatac()"  class="layui-btn-outer" lay-submit=""  value="导出本次查询数据">-->
        <a  href="javascript:history.go(-1);"  class="goBack"><span class="iconfont icon-fanhui">&nbsp;返回</span></a>
   </div>

 </div>
  <!--  表格 -->
<div class="detail">
     <table class="layui-table" lay-skin="line">
      <thead >
         <tr>
           <th>编&emsp;号</th>
           <th>小&emsp;区</th>
           <th>单&emsp;元</th>
           <th>时&emsp;间</th>
           <th>消费类型</th>
           <th>消费金额</th>
         </tr>
      </thead>
      <tbody class="org-table">
      </tbody>
      </table>
    <div id="page-fen">
        <div id="page-num"></div>
    </div>
  </div>

   <!--  表格部分 -->
  <script src="../lib/jquery.js" type="text/javascript"></script>
  <script type="text/javascript" src="../layui/layui.js"></script>
  <script src="../lib/js/jquery.cookie.js" type="text/javascript"></script>
   <script>
      layui.use(['jquery', 'laydate','form','laypage','layer'], function(){
         var  $ = layui.jquery;
         var   laydate = layui.laydate;
         var   laypage = layui.laypage;

         var table_Ida =localStorage.getItem("table_Ida");
             console.log(table_Ida);
         var params = {};
             params.table_Ida = table_Ida;
         var start = {
            min: '2000-06-16 23:59:59'
            ,max: '2099-06-16 23:59:59'
            ,istoday: false
            ,choose: function(datas){
              end.min = datas; //开始日选好后，重置结束日的最小日期
              end.start = datas //将结束日的初始值设定为开始日
            }
          };
        var end = {
            min: '2000-06-16 23:59:59'
            ,max: '2099-06-16 23:59:59'
            ,istoday: false
            ,choose: function(datas){
              start.max = datas; //结束日选好后，重置开始日的最大日期
            }
          };
          document.getElementById('start').onclick = function(){
            start.elem = this;
            laydate(start);
         };
         document.getElementById('end').onclick = function(){
           end.elem = this;
           laydate(end);
         };

          $("#search").off("click").on("click",function(){
              var value= $("input[name='items']:checked").attr("value");
                  console.log('value',value);
              localStorage.setItem("value",value);
                  if(value == "chongzhi"){
                      searchCZ();
                  }else if(value == "chengti"){
                      searchCT();
                  }else{
                      searchTable();
                  }
          });
      var pages = {};
          searchTable();
      function searchTable(curra){
          var startDate =$("#start").val();
          startDate = startDate.replace(/-/g, '');
          console.log(startDate);

          var endDate =$("#end").val();
          endDate = endDate.replace(/-/g, '');

          localStorage.setItem("startDatea",startDate);
          localStorage.setItem("endDatea",endDate);

          $.ajax({
          url: '../../organization_manage/getFlowDetails',
          type: 'get',
          dataType: 'json',
          data:{
              user_id:table_Ida,
              current_page: curra || 1,
              limit:10,
              start_date:startDate||0,
              end_date:endDate||0,
              type:0,
          }
      })
        .done(function(response){
              console.log("getFlowDetails success",response);
          if(response.resultCode == 200){
          var str= '';
              console.log(response.page.list.length);
          if(response.page.list.length){
            for(var i=0;i<response.page.list.length;i++){
            str +=
            '<tr>'+
            '<td>'+ response.page.list[i].flow_id +'</td>'+
            '<td>'+ response.page.list[i].building_name +'</td>'+
            '<td>'+ response.page.list[i].zhuang_danyuan+'</td>'+
            '<td>'+ response.page.list[i].consume_time+'</td>'+
            '<td>'+ response.page.list[i].consume_type+'</td>'+
            '<td>'+ response.page.list[i].consume_money+'</td>'+
            '</tr>'
          }

          $(".org-table").html(str);
              show();
            pages.total = response.page.total;
            console.log(pages.total);

            pages.current_page = response.page.current_page;
            console.log(pages.current_page);

            pages.totalPages = Math.ceil(pages.total/10);

              laypage({
                  cont: 'page-num'
                  ,pages: pages.totalPages
                  ,curr: pages.current_page
                  ,first: 1
                  ,last:false
                  ,prev: '<em><</em>'
                  ,next: '<em>></em>'
                  ,jump: function(obj, first){
                      var curra = obj.curr;
                      console.log(curra);
                      localStorage.setItem("curra",curra);
                      if(!first){
                          searchTable(curra);
                      };
                  }
              })//分页
        }else{
          str = '<tr><td colspan="7">暂无数据</td></tr>';
          $(".org-table").html(str);
              hidden()
            }
           }
        })
        .fail(function(response){
              console.log("fail",response);
              if(response.resultCode=='001'){
                console.log("param is not found");
                }
            });
        }
          function show(){
              document.getElementById("page-fen").style.display="";
          };
          function hidden(){
              document.getElementById("page-fen").style.display="none";
          }
      // 充值
          function searchCZ(currz){
              var startDate =$("#start").val();
              startDate = startDate.replace(/-/g, '');
              console.log(startDate);

              var endDate =$("#end").val();
              endDate = endDate.replace(/-/g, '');

              localStorage.setItem("startDatez",startDate);
              localStorage.setItem("endDatez",endDate);

              $.ajax({
                  url: '../../organization_manage/getChongzhiDetails',
                  type: 'get',
                  dataType: 'json',
                  data:{
                      user_id:table_Ida,
                      current_page: currz || 1,
                      limit:10,
                      start_date:startDate||0,
                      end_date:endDate||0,
                      type:0
                  }
              })
                  .done(function(response){
                      console.log("getFlowDetails success",response);
                      if(response.resultCode == '200'){
                          var str= '';
                          console.log(response.page.list.length);
                          if(response.page.list.length){
                              for(var i=0;i<response.page.list.length;i++){
                                  str +=
                                      '<tr>'+
                                      '<td>'+ response.page.list[i].flow_id +'</td>'+
                                      '<td>'+ response.page.list[i].building_name +'</td>'+
                                      '<td>'+ response.page.list[i].zhuang_danyuan+'</td>'+
                                      '<td>'+ response.page.list[i].consume_time+'</td>'+
                                      '<td>'+ response.page.list[i].consume_type+'</td>'+
                                      '<td>'+ response.page.list[i].consume_money+'</td>'+
                                      '</tr>'
                              }

                              $(".org-table").html(str);
                              show();
//分页显示
                              pages.total = response.page.total;
                              console.log(pages.total);

                              pages.current_page = response.page.current_page;
                              console.log(pages.current_page);

                              pages.totalPages = Math.ceil(pages.total/10);

                              laypage({
                                  cont: 'page-num'
                                  ,pages: pages.totalPages
                                  ,curr: pages.current_page
                                  ,first: false
                                  ,last:false
                                  ,prev: '<em><</em>'
                                  ,next: '<em>></em>'
                                  ,jump: function(obj, first){
                                      var currz = obj.curr;
                                      console.log(currz);
                                      localStorage.setItem("currz",currz);
                                      if(!first){
                                          searchCZ(currz);
                                      }
                                  }
                              })
                          }
                          else{
                              str = '<tr><td colspan="7">暂无数据</td></tr>';
                              $(".org-table").html(str);
                              hidden();
                          }
                      }
                  })
                  .fail(function(response){
                      console.log("fail",response);
                      if(response.resultCode=='001'){
                          console.log("param is not found");
                      }
                  });
          }
          //乘梯
          function searchCT(currt){
              var startDate =$("#start").val();
              startDate = startDate.replace(/-/g, '');

              var endDate =$("#end").val();
              endDate = endDate.replace(/-/g, '');

              localStorage.setItem("startDatet",startDate);
              localStorage.setItem("endDatet",endDate);

              var value =localStorage.getItem("value");
              console.log(value);

              $.ajax({
                  url: '../../organization_manage/getChengtiDetails',
                  type: 'get',
                  dataType: 'json',
                  data:{
                      user_id:table_Ida,
                      current_page: currt || 1,
                      limit:10,
                      start_date:startDate||0,
                      end_date:endDate||0,
                      type:0
                  }
              })
                  .done(function(response){
                      console.log("getFlowDetails success",response);
                      if(response.resultCode == '200'){
                          var str= '';
                          console.log(response.page.list.length);
                          if(response.page.list.length){
                              for(var i=0;i<response.page.list.length;i++){
                                  str +=
                                      '<tr>'+
                                      '<td>'+ response.page.list[i].flow_id +'</td>'+
                                      '<td>'+ response.page.list[i].building_name +'</td>'+
                                      '<td>'+ response.page.list[i].zhuang_danyuan+'</td>'+
                                      '<td>'+ response.page.list[i].consume_time+'</td>'+
                                      '<td>'+ response.page.list[i].consume_type+'</td>'+
                                      '<td>'+ response.page.list[i].consume_money+'</td>'+
                                      '</tr>'
                              }

                              $(".org-table").html(str);
                              show();
//分页显示
                              pages.total = response.page.total;
                              console.log(pages.total);


                              pages.current_page = response.page.current_page;
                              console.log(pages.current_page);

                              pages.totalPages = Math.ceil(pages.total/10);

                              laypage({
                                  cont: 'page-num'
                                  ,pages: pages.totalPages
                                  ,curr: pages.current_page
                                  ,first: 1
                                  ,last:false
                                  ,prev: '<em><</em>'
                                  ,next: '<em>></em>'
                                  ,jump: function(obj, first){ //触发分页后的回调
                                      var currt = obj.curr;
                                      console.log(currt);
                                      localStorage.setItem("currt",currt);
                                      if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
                                          searchCT(currt);
                                      }
                                  }
                              })
                          }
                          else{
                              str = '<tr><td colspan="7">暂无数据</td></tr>';
                              $(".org-table").html(str);
                              hidden();
                          }
                      }
                  })
                  .fail(function(response){
                      console.log("fail",response);
                      if(response.resultCode=='001'){
                          console.log("param is not found");
                      }
                  });
          }
    });
      // 超链接导出当前查询数据
      function outerDatac(){
          var table_Ida =localStorage.getItem("table_Ida");
          console.log(table_Ida);

          var startDatea =localStorage.getItem("startDatea");
          console.log(startDatea);

          var endDatea =localStorage.getItem("endDatea");
          console.log(endDatea);

          var startDatet =localStorage.getItem("startDatet");
          console.log(startDatet);

          var endDatet =localStorage.getItem("endDatet");
          console.log(endDatet);

          var startDatez =localStorage.getItem("startDatez");
          console.log(startDatez);

          var endDatez =localStorage.getItem("endDatez");
          console.log(endDatez);

          var value =localStorage.getItem("value");
          console.log(value);

          var curra=localStorage.getItem("curra");
          var currt=localStorage.getItem("currt");
          var currz=localStorage.getItem("currz");

          if(value == "flow"){

              window.location.href='http://wrench-tida.tunnel.echomod.cn/organization_manage/getFlowDetails?user_id='+table_Ida+'&start_date='+startDatea||0+'&end_date='+endDatea||0+'&current_page='+curra+'&limit=10&type=1'
              return;
          }else if(value == "chengti"){

              window.location.href = 'http://wrench-tida.tunnel.echomod.cn/organization_manage/getChongzhiDetails?user_id='+table_Ida+'&start_date='+startDatez||0+'&end_date='+endDatez||0+'&current_page='+currz+'&limit=10&type=1'
              return;
          }else if(value == "chongzhi"){

              window.location.href='http://wrench-tida.tunnel.echomod.cn/organization_manage/getChengtiDetails?user_id='+table_Ida+'&start_date='+startDatet||0+'&end_date='+endDatet||0+'&current_page='+currt+'&limit=10&type=1'
              return;
          }

      };
  </script>
 </body>
</html>
